#include "sll_list.h"

void sll_list_init(sll_list_t *l)
{
    l->next = l->prev = l;
}

//insert a node after a list
void sll_list_insert_after(sll_list_t *l, sll_list_t *n)
{
    l->next->prev = n;
    n->next = l->next;
    
    l->next = n;
    n->prev = l;
}

void sll_list_insert_before(sll_list_t *l, sll_list_t *n)
{
    l->prev->next = n;
    n->prev = l->prev;
    
    l->prev = n;
    n->next = l;
}

//remove node from list
void sll_list_remove(sll_list_t *n)
{
    n->next->prev = n->prev;
    n->prev->next = n->next;
    
    n->next = n->prev = n;
}

int sll_list_empty(sll_list_t *l)
{
    if(l->next == l)
        return 1;
    else return 0;
}












